<?php 
/**
 * alltosun.com admin_log controller
 * ============================================================================
 * 版权所有 (C) 2009-2011 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 高昂 (gaoa@alltosun.com) $
 * $Date: 2016-4-2 下午3:37:10 $
 * $Id: $
 */

class Action
{
    private $per_page = 20;
    
    public function index()
    {
        $page          = Request::Get('page_no', 1);
        $action        = Request::Get('action', '');
        $is_advenced   = Request::getParam('is_advenced', 0);
        $search_filter = Request::getParam('search_filter', array());
        $test          = Request::getParam('test', 0);
        
        // 拼装搜索条件
        $filter = array();
        
        if (isset($search_filter['start_date']) && $search_filter['start_date']) {
            $filter['`add_time` >= '] = $search_filter['start_date'].' 00:00:00';
        }
        if (isset($search_filter['end_date']) && $search_filter['end_date']) {
            $filter['`add_time` <= '] = $search_filter['end_date'].' 23:59:59';
        }
        
        if (isset($search_filter['realname']) && $search_filter['realname']) {
            $filter['admin_id'] = user_helper::get_user_id_by_realname($search_filter['realname']);
        }
        
        if (isset($search_filter['realname']) && $search_filter['realname']) {
            $filter['admin_id'] = user_helper::get_user_id_by_realname($search_filter['realname']);
        }
        
        if ($action) {
            $filter['action'] = $action;
        }
        
        if (!$filter) {
            $filter = array(1 => 1);
        }
        
        $admin_log_list = get_data_list('admin_log', $filter, 'ORDER BY `id` DESC', $page, $this->per_page);
        if ($admin_log_list) {
            foreach ($admin_log_list as $k => $v) {
                $admin_log_list[$k]['menu_title'] = admin_menu_helper::get_menu_title_by_module($v['res_name']);
                $admin_log_list[$k]['action_name'] = admin_log_config::$action_list_str[$v['action']];
                $admin_info = user_helper::get_user_info($v['admin_id']);
                if ($admin_info) {
                    $admin_log_list[$k]['admin_user_name'] = $admin_info['realname'] ? $admin_info['realname'] : $admin_info['nickname'];
                } else {
                    $admin_log_list[$k]['admin_user_name'] = '未知人员';
                }
            }
        }
        
        Response::assign('test', $test);
        Response::assign('page_no', $page);
        Response::assign('action', $action);
        Response::assign('is_advenced', $is_advenced);
        Response::assign('search_filter', $search_filter);
        Response::assign('admin_log_list', $admin_log_list);
        
        Response::display('admin/admin_log_list.html');
    
    }
}

?>